var htmlCodes = [
    '<div id="printZhongTong" v-cloak>',
    '    <style>',
    '        .el-row {',
    '            height: 25px;',
    '            font-size: smaller;',
    '        }',
    '    </style>',
    '    <el-dialog title="打印中通快递" :visible.sync="dialogVisible">',
    '    <!--startprint-->',
    '    <div id="forPrint" style="width: 210mm">',
    '        <br><br><br><br>',
    '        <table width="100%" border="0" cellpadding="0" cellspacing="0" style="font-size: smaller;">',
    '            <tbody>',
    '            <tr>',
    '                <td width="25%">{{sellerInfo.sellerName}}</td>',
    '                <td width="25%">{{sellerInfo.area}}</td>',
    '                <td width="25%">{{erpOrder.shipName}}</td>',
    '                <td width="25%">{{erpOrder.shipArea}}</td>',
    '            </tr>',
    '            <tr><td width="25%" colspan=4>&nbsp;</td></tr>',
    '            <tr>',
    '                <td width="25%" colspan=2>{{sellerInfo.addr}}</td>',
    '                <td width="25%" colspan=2>{{erpOrder.shipAddr}}</td>',
    '            </tr>',
    '            <tr><td width="25%" colspan=4>&nbsp;</td></tr>',
    '            <tr>',
    '                <td width="25%" colspan=2>{{sellerInfo.doorheadName}}</td>',
    '                <td width="25%" colspan=2>{{erpOrder.memberName}}</td>',
    '            </tr>',
    '            <tr><td width="25%" colspan=4>&nbsp;</td></tr>',
    '            <tr>',
    '                <td width="25%">{{sellerInfo.sellerMobile}}</td>',
    '                <td width="25%">{{sellerInfo.shipZip}}</td>',
    '                <td width="25%">{{erpOrder.shipMobile}}</td>',
    '                <td width="25%">{{erpOrder.shipZip}}</td>',
    '            </tr>',
    '            </tbody>',
    '        </table>',
    '    </div>',
    '    <!--endprint-->',
    '    <span slot="footer" class="dialog-footer">',
    '            <el-button @click="dialogVisible = false" size="small">取 消</el-button>',
    '            <el-button type="primary" @click="doPrint" size="small">打 印</el-button>',
    '        </span>',
    '    </el-dialog>',
    '</div>'
].join("");
Vue.component('zy-print-zhongtong', {
    template: htmlCodes,
    props: {
        orderNo: '',
    },
    data: function () {
        return {
            erpOrder: {},
            sellerInfo: {},
            dialogVisible: false,
        }
    },
    methods: {
        doPrint: function () {
            // var printData = document.getElementById("forPrint").innerHTML; // 只打印 forPrint 这个div中的内容。
            // window.document.body.innerHTML = printData;   //把 html 里的数据 复制给 body 的 html 数据 ，相当于重置了整个页面的 内容
            // window.print()
            // window.location.reload();
            //将原有页面还原到页面
            // document.getElementById("forPrint").innerHTML = printData;

            var newWin=window.open('about:blank', '', '');
            var titleHTML=document.getElementById("forPrint").innerHTML;
            newWin.document.write(titleHTML);
            newWin.document.location.reload();
            newWin.print();
        },
        getOrderData: function (orderNo) {
            var self=this
            $.get(baseURL + "logistics/erplogistics/expressFormInfo/" + orderNo, function (r) {
                if (r.code == 0) {
                    self.erpOrder = r.erpOrder;
                    self.sellerInfo = r.sellerInfo;
                    self.dialogVisible=true
                } else {
                    alert(r.msg);
                }

            })
        },
    }


})

